<%########################### 
#
#  Upcoming reservations
#
#############################%>
<% if @confirmed_reservations.size == 0  && @waiting_list_signups.size == 0 %>
  <div class="empty-list">
    <p>You don't have any upcoming reservations. Why don't you <%= link_to "take a look at the available topics", topics_path %>
      and see what looks interesting?</p>
  </div>
<% else %>
  <% if @confirmed_reservations.size > 0 %>
    <div class="reservation-group content-section">
      <h2>Confirmed Reservations</h2>
      <ul class="reservation-list">
        <% @confirmed_reservations.each do |reservation| %>
          <li>
            <div>
              <div class="reservation-name">
                <%= link_to reservation.session.topic.name, reservation.session, :class => 'topic' %>
                <%= link_to formatted_time_range(reservation.session.next_time, reservation.session.topic.minutes), reservation.session, :class => 'date' %>
              </div>
              <div class="reservation-actions">
                <div class="download-link download-calendar">
                  <%= link_to "Add reservation to calendar", 
                      reservation_path(reservation, format: :ics) %>
                </div>
                <%= link_to_edit_reservation(reservation) %>
                <div class="delete-link">
                  <%= link_to "Cancel Reservation", reservation, 
                        method: :delete, 
                        data: { confirm: "Are you sure you want to cancel your reservation for \"#{reservation.session.topic.name}\"?" } 
                  %>
                </div>
              </div>
            </div>
          </li>
        <% end %>
      </ul>
    </div>
  <% end %>

  <% if @waiting_list_signups.size > 0 %>
  <div class="reservation-group content-section">
    <h2>Waiting List Signups</h2>
    <ul class="reservation-list">
      <% @waiting_list_signups.each do |reservation| %>
        <li>
          <div>
            <div class="reservation-name">
              <%= link_to reservation.session.topic.name, reservation.session, :class => 'topic' %>
              <%= link_to formatted_time_range(reservation.session.time, reservation.session.topic.minutes), reservation.session, :class => 'date' %>
            </div>
            <div class="reservation-actions">
              <div class="download-link download-calendar">
                <%= link_to "Add reservation to calendar", 
                  reservation_path(reservation, format: :ics) %>
              </div>
              <%= link_to_edit_reservation(reservation) %>
              <div class="delete-link">
                <%= link_to "Remove Name From Waiting List", reservation, 
                      method: :delete, 
                      data: { confirm: "Are you sure you want to remove your name from the waiting list for \"#{reservation.session.topic.name}\"?" }
                %>
              </div>
            </div>
          </div>
        </li>
      <% end %>
    </ul>
  </div>
  <% end %>

<% end %>


<%########################### 
#
#  Past reservations
#
#############################%>
<% if @past_reservations.size > 0 %>
<div class="reservation-group content-section">
  <h2>Sessions Attended</h2>
  <ul class="reservation-list">
    <% @past_reservations.each do |reservation| %>
      <li>
        <div>
          <div class="reservation-name">
            <%= link_to reservation.session.topic.name, reservation.session, :class => 'topic' %>
            <%= link_to formatted_time_range(reservation.session.time, reservation.session.topic.minutes), reservation.session, :class => 'date' %>
          </div>
          <div class="reservation-actions">
            <%= certificate_link(reservation) %>
            <%= survey_link(reservation) %>
          </div>
        </div>
      </li>
    <% end %>
  </ul>
</div>
<% end %>


<%########################### 
#
#  Upcoming instructor sessions
#
#############################%>
<% if @user.upcoming_sessions.size > 0 %>
  <div class="reservation-group content-section">
    <h2>Upcoming Instructor Sessions</h2>
    <ul class="reservation-list">
      <% @user.upcoming_sessions.take(5).each do |session| %>
        <li>
          <div>
            <div class="reservation-name">
              <%= link_to session.topic.name, session, :class => 'topic' %>
              <%= link_to formatted_time_range(session.time, session.topic.minutes), session, :class => 'date' %>
            </div>            
          </div>
        </li>
      <% end %>
    </ul>
  </div>
<% end %>

<% if @user.upcoming_sessions.size > 5 %>
  <div class="user-link">
    <%= link_to "View #{@user.upcoming_sessions.size - 5} more upcoming and all past instructor sessions", @user %>
  </div>
<% elsif @user.sessions.present? %>
  <div class="user-link">
    <%= link_to "View all past instructor sessions", @user %>
  </div>
<% end %>


<%########################### 
#
#  Admin links
#
#############################%>
<% content_for :admin_tools do %>
  <% if current_user.admin? %>
    <div class="view-person">
      <h3>View Another Person:</h3>
      <%= form_tag(reservations_path, :method => "get") do %>
        <%= label_tag "user_login", "Net ID", :class => "admin-netid-label" %>
        <%= text_field_tag "user_login", nil, :size => 7 %>
        <%= submit_tag "Go" %>
      <% end %>
    </div>
  <% end %>
<% end %>
